<!DOCTYPE html>
<html lang="cn">
<head>
<#include "/admin/common/app.ftl">
<link rel="stylesheet" href="http://cdn.bootcss.com/jquery-treegrid/0.2.0/css/jquery.treegrid.min.css">
<script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="http://cdn.bootcss.com/jquery-treegrid/0.2.0/js/jquery.treegrid.min.js"></script>
<script src="http://cdn.bootcss.com/jquery-treegrid/0.2.0/js/jquery.treegrid.bootstrap3.min.js"></script>
</head>
<body class="container-fluid">
	<div class="page-title">
		<div class="title-env">
			<h1 class="title">栏目管理</h1>
			<p class="description">Plain text boxes, select dropdowns and other basic form elements</p>
		</div>
		<div class="breadcrumb-env">
			<a class="btn btn-primary" href="${basePath}/cms/category/edit">ADD</a>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-12">
			<table class="table tree">
				<thead>
					<tr>
						<th>名称</th>
						<th>别名</th>
						<th>文章数量</th>
						<th>操作</th>
					</tr>
				</thead>
				<#list list as item>
				<tr class="treegrid-${item.id} <#if item.pid && item.pid != 0>treegrid-parent-${item.pid}</#if>">
					<td> ${item.name}</td>
					<td>${item.code}</td>
					<td>${item.articleCount}</td>
					<td><a href="${basePath}/cms/category/edit?id=${item.id}"><span class="fa fa-edit"></span></a> 
					/ <a href="javascript:void(0);" onclick="del(${item.id})"><span class="fa fa-trash"></span></a></td>
				</tr>
				</#list>
			</table>
		</div>
	</div>
	<script type="text/javascript">
		$(function() {
			$('.tree').treegrid({
				expanderExpandedClass : 'glyphicon glyphicon-minus',
				expanderCollapsedClass : 'glyphicon glyphicon-plus'
			});
		});
		function del(id) {
			if (confirm("确认删除?")) {
				jQuery.ajax({
					url : "${basePath}/cms/category/del?id=" + id,
					dataType : "json",
					success : function(json) {
						if (json.flag) {
							window.location.reload();
						} else {
							alert(json.msg);
						}
					}
				});
			}
		}
	</script>
</body>
</html>